<?php
class Student {
    public $name='tom';
    protected $sex='男';
    private $age=22;

    public function show() {
        foreach($this as $k=>$v) {
            echo "{$k}-{$v}<br>";
        }
    }
}
//测试
$stu=new Student;
foreach($stu as $k=>$v) {
    echo "{$k}-{$v}<br>";
}
echo '<hr>';
$stu->show();

//结论：遍历到当前位置所能访问到属性